@extends('admin.base')
	@section('content')
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <i class="fa fa-calendar"></i>
			商品信息管理 
          </h1>
          <ol class="breadcrumb">
            <li><a href="{{url('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商品信息管理</a></li>
            <li class="active">添加商品信息</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <!-- right column -->
            <div class="col-md-12">
              <!-- Horizontal Form -->
              <div class="box box-primary">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-plus"></i> 添加商品信息</h3>
                </div><!-- /.box-header -->
                <!-- form start -->
                <form class="form-horizontal" method="post" action='{{url("admin/minfo/$minfo->mid")}}'>
				  <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
				  <input type="hidden" name="_method" value="put">
				  <input type="hidden" name="mid" value="{{$minfo->mid}}"/>
                  <div class="box-body">
					<div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品板块</label>
                      <div class="col-sm-4" class="form-control">
						<select name="fid" id="fid" class="form-control" id="level">
							@foreach($forum as $forum)
								<option value="{{$forum->id}}" 
								@if($minfo->fid == $forum->id)
									selected
								@endif
								>&nbsp;&nbsp;{{$forum->name}}</option>
							@endforeach
						</select>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品类别</label>
                      <div class="col-sm-4" id="" class="form-control">
						<select name="gid" id="gid" class="form-control" id="level">
							@foreach($genre as $genre)
							@if($genre->fid )
								<option value="{{$genre->id}}"
								@if($minfo->gid == $genre->id)
									selected
								@endif
								>&nbsp;&nbsp;{{$genre->name}}</option>
							@endif
							@endforeach
						</select>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品名称</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control" value="{{$minfo->name}}" name="name" placeholder="商品名称">
                      </div>
                    </div>	
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品简介</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control" value="{{$minfo->brief}}" name="brief" placeholder="商品简介">
                      </div>
                    </div>
					@foreach($pag as $pag)
					@if($search->gid == $pag->gid && $pag->name != "价格")
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">{{$pag->name}}</label>
                      <div class="col-sm-4">
						<?php 
							/**
								将数据库中标签表中对应的标签遍历出来
								$n（标签表中的field）等于 商品搜索表中的搜索字段
								$field（商品搜索表中字段指向的该商品信息） 等同于 $search->搜索字段
							*/
							$n = ($pag->field);
							$field = $search->$n;?>
                        <input type="text" class="form-control"  value="{{$field}}" name="{{$pag->field}}" placeholder="{{$pag->name}}">
                      </div>
                    </div>
					@endif
					@endforeach
					
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品价格(￥)</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control" value="{{$search->price}}" name="price" placeholder="商品价格">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品数量</label>
                      <div class="col-sm-4">
                        <input type="text" class="form-control" value="{{$minfo->number}}" name="number" placeholder="商品数量">
                      </div>
                    </div>
					<div class="form-group">
                      <label for="inputPassword3" value="{{$minfo->content}}" class="col-sm-2 control-label">商品信息</label>
                      <div class="col-sm-10">
                        <textarea id="editor1" name="content" rows="10" cols="80">{{$minfo->content}}</textarea>
                      </div>
                    </div>
					<div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">商品状态</label>
                      <div class="col-sm-4" class="form-control">
						<select name="status" class="form-control" id="level">
							<option value="wait" 
							@if($minfo->status == "wait")
								selected
							@endif
							>&nbsp;&nbsp;新款</option>
							<option value="on" 
							@if($minfo->status == "on")
								selected
							@endif
							>&nbsp;&nbsp;热卖</option>
							<option value="off" 
							@if($minfo->status == "off")
								selected
							@endif
							>&nbsp;&nbsp;下架</option>
						</select>
                      </div>
                    </div><!-- /.box-body -->
                  <div class="box-footer">
				    <div class="col-sm-offset-2 col-sm-1">
						<button type="submit" class="btn btn-primary">修改</button>
                    </div>
					<div class="col-sm-1">
						<button type="reset"  class="btn btn-primary">重置</button>
					</div>
                  </div><!-- /.box-footer -->
                </form>
				<div class="row"><div class="col-sm-12">&nbsp;</div></div>
              </div><!-- /.box -->
            </div><!--/.col (right) -->
          </div>   <!-- /.row -->
        </section><!-- /.content -->
    @endsection